import subprocess
import sys
sys.path.append('../utils/')
sys.path.append('./utils/')

from mysql_connector import load_conf

def test():
    """
    开始测试, 直接调用 tpcc_start
    """
    conf = load_conf()

    host = conf["host"]
    port = conf["port"]
    user = conf["user"]
    passwd = conf["password"]
    db = conf["database"]

    w = conf["-w"]
    c = conf["-c"]
    r = conf["-r"]
    l = conf["-l"]
    i = conf["-i"]
    f = conf["-f"]

    print('开始测试!')
    subprocess.call('./tpcc_source_code/tpcc_start -h %s -p %s -d %s -u %s -p %s -w %s -c %s -r %s -l %s -i %s -f %s' % 
                    (host, port, db, user, passwd, w, c, r, l, i, f), shell=True)
    print('测试结束, 数据已存入 %s ' % f)